<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.0.1/weui.min.css">
    <script type="text/javascript" src="https://res.wx.qq.com/t/wx_fed/cdn_libs/res/weui/1.2.3/weui.min.js"></script>
    <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <script src="https://cdn.bootcdn.net/ajax/libs/zepto/1.2.0/zepto.min.js"></script>
    <script src="https://unpkg.com/ming_mock/index.js"></script>

</head>
<body>

<div id="root">
    <button onclick="scan()">scan</button>
</div>
</body>
</html>

<script type="module">
    import JweixinPlugin from './JweixinPlugin.js';
    app.use(new JweixinPlugin({
        wxConfigUrl:"/proxyScan"
    }));
</script>

<script>
    function scan(){
        MIO.wxConfig({
            readyCallBack:()=>{
                wx.scanQRCode({
                    desc: 'scanQRCode desc',
                    needResult: 1,
                    scanType: ["qrCode","barCode"],
                    success: function (res) {
                        try{
                            alert(res)
                        }catch(e){
                            alert('非法条形码');
                        }
                    },
                    error: function(err){
                        if(err.errMsg.indexOf('function_not_exist') > 0){
                            alert('版本过低请升级');
                        }
                    }
                });
            }})
    }
</script>










<script>
    function scan1111(cb) {
        const page = window.location.href.split("#")[0];
        var timestamp = Date.now();
        $.ajax({
            url: "proxyScan",
            type: 'get',
            data: {
                page: page,
                timestamp: timestamp
            },
            dataType: "json",
            success: function (res) {
                console.log("========>",res)
                var config = {};
                config.appId = res.data.appId;
                config.signature = res.data.signature;
                config.nonceStr = res.data.nonceStr;
                config.timestamp = timestamp;
                config.jsApiList = ['chooseImage'];
                config.debug=true;
                wx.config(config);
                wx.ready(function () {
                    console.log("wxready==>","AAAAAAAAAAA")
                    wx.chooseImage({
                        count: 1, // 默认9
                        sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
                        sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
                        success: function (res) {
                            var localIds = res.localIds; // 返回选定照片的本地ID列表，localId可以作为img标签的src属性显示图片
                            console.log("===",localIds)
                        }
                    });
                    console.log("wxready==>","BBBBBBBBBBBBBBBBBBBBBB")

                });
            }
        });
    }

    // scan(u=>{
    //     console.log(u)
    // })
</script>


<!--<script src="https://cdn.bootcss.com/vConsole/3.2.0/vconsole.min.js"></script>-->
<!--<script>-->
<!--    var vConsole = new VConsole();-->
<!--</script>-->
